var AssertionTests = {
  /* Assert.fail(message) */
  AssertFailTest: {
    testThrowsException: function() {
      var thrown = false;

      try {
        Assert.fail();
      } catch (e) {
        if (e instanceof AssertFailedException) {
          thrown = true;
        }
      }

      Assert.isTrue(thrown,
                    'Assert.fail() should always throw an AssertFailedException.');
    },

    testPassesDefaultMessageWhenNoMessageSupplied: function() {
      var expected = Assert._defaultMessages.fail,
      actual = '';

      try {
        Assert.fail();
      } catch (e) {
        actual = e.toString();
      }

      Assert.areEqual(expected, actual,
                      'Assert.fail() should use the default failure message ' +
                      'when no message was passed.');
    },

    testPassesSuppliedMessage: function() {
      var expected = 'This is the failure message.',
      actual = '';

      try {
        Assert.fail(expected);
      } catch (e) {
        actual = e.toString();
      }

      Assert.areEqual(expected, actual,
                      'Assert.fail() should use the user provided failure ' +
                      'message when present.');
    }
  },

  /* Assert.isNull(val, message) */
  AssertIsNullTest: {
    testThrowsExceptionWhenValueIsNotNull: function() {
      var thrown = false;

      try {
        Assert.isNull('');
      } catch (e) {
        if (e instanceof AssertFailedException) {
          thrown = true;
        }
      }

      Assert.isTrue(thrown,
                    'Assert.isNull() should throw an AssertFailedException when ' +
                    'the provided value is not null.');
    },

    testDoesNotThrowExceptionWhenValueIsNull: function() {
      var thrown = false;

      try {
        Assert.isNull(null);
      } catch (e) {
        thrown = true;
      }

      Assert.isFalse(thrown,
                     'Assert.isNull() should not throw an exception when the ' +
                     'provided value is null.');
    },

    testPassesDefaultMessageWhenNoMessageSupplied: function() {
      var expected = Assert._defaultMessages.isNull,
      actual = '';

      try {
        Assert.isNull('', expected);
      } catch (e) {
        actual = e.toString();
      }

      Assert.areEqual(expected, actual,
                      'Assert.isNull() should use the default failure message ' +
                      'when no message was passed.');
    },

    testPassesSuppliedMessage: function() {
      var expected = 'This is the failure message.',
      actual = '';

      try {
        Assert.isNull('', expected);
      } catch (e) {
        actual = e.toString();
      }

      Assert.areEqual(expected, actual,
                      'Assert.isNull() should use the user provided failure ' +
                      'message when provided.');
    }
  },

  /* Test Assert.isNotNull(val, message) */
  AssertIsNotNullTest: {
    testThrowsExceptionWhenValueIsNull: function() {
      var thrown = false;

      try {
        Assert.isNotNull(null);
      } catch (e) {
        if (e instanceof AssertFailedException) {
          thrown = true;
        }
      }

      Assert.isTrue(thrown,
                    'Assert.isNotNull() should throw an AssertFailedException ' +
                    'when the provided value is null.');
    },

    testDoesNotThrowExceptionWhenValueIsNotNull: function() {
      var thrown = false;

      try {
        Assert.isNotNull('');
      } catch (e) {
        thrown = true;
      }

      Assert.isFalse(thrown,
                     'Assert.isNotNull() should not throw an exception when the ' +
                     'provided value is not null.');
    },

    testPassesDefaultMessageWhenNoMessageSupplied: function() {
      var expected = Assert._defaultMessages.isNotNull,
      actual = '';

      try {
        Assert.isNotNull(null, expected);
      } catch (e) {
        actual = e.toString();
      }

      Assert.areEqual(expected, actual,
                      'Assert.isNotNull() should use the default failure ' +
                      'message when no message was passed.');
    },

    testPassesSuppliedMessage: function() {
      var expected = 'This is the failure message.',
      actual = '';

      try {
        Assert.isNotNull(null, expected);
      } catch (e) {
        actual = e.toString();
      }

      Assert.areEqual(expected, actual,
                      'Assert.isNotNull() should use the user provided failure message ' +
                      'when provided.');
    }
  },

  /* Assert.isTrue(val, message) */
  AssertIsTrueTest: {
    testThrowsExceptionWhenValueIsFalse: function() {
      var thrown = false;

      try {
        Assert.isTrue(false);
      } catch (e) {
        thrown = true;
      }

      if (!thrown) {
        throw new AssertFailedException('Assert.isTrue() should throw an ' +
                                        'AssertFailedException when the ' +
                                        'provided value does not evaluate ' +
                                        'to true.', true, false);
      }
    },

    testDoesNotThrowExceptionWhenValueIsTrue: function() {
      var thrown = false;

      try {
        Assert.isTrue(true);
      } catch (e) {
        thrown = true;
      }

      if (thrown) {
        throw new AssertFailedException('Assert.isTrue() should not throw an ' +
                                        'exception when the provided value ' +
                                        'evaluates to true.', false, true);
      }
    },

    testPassesDefaultMessageWhenNoMessageSupplied: function() {
      var expected = Assert._defaultMessages.isTrue,
      actual = '';

      try {
        Assert.isTrue(false);
      } catch (e) {
        actual = e.toString();
      }

      Assert.areEqual(expected, actual,
                      'Assert.isTrue() should use the default failure message ' +
                      'when no message was passed.');
    },

    testPassesSuppliedMessage: function() {
      var expected = 'This is the failure message.',
      actual = '';

      try {
        Assert.isTrue(false, expected);
      } catch (e) {
        actual = e.toString();
      }

      Assert.areEqual(expected, actual,
                      'Assert.isTrue() should use the user provided failure ' +
                      'message when provided.');
    }
  },

  /* Assert.isFalse(val, message) */
  AssertIsFalseTest: {
    testThrowsExceptionWhenValueIsTrue: function() {
      var thrown = false;

      try {
        Assert.isFalse(true);
      } catch (e) {
        thrown = true;
      }

      if (!thrown) {
        throw new AssertFailedException('Assert.isFalse() should throw an ' +
                                        'AssertFailedException when the ' +
                                        'provided value does not evaluate ' +
                                        'to false.', true, false);
      }
    },

    testDoesNotThrowExceptionWhenValueIsFalse: function() {
      var thrown = false;

      try {
        Assert.isFalse(false);
      } catch (e) {
        thrown = true;
      }

      if (thrown) {
        throw new AssertFailedException('Assert.isFalse() should not throw an ' +
                                        'exception when the provided value ' +
                                        'evaluates to false.', false, true);
      }
    },

    testPassesDefaultMessageWhenNoMessageSupplied: function() {
      var expected = Assert._defaultMessages.isFalse,
      actual = '';

      try {
        Assert.isFalse(true);
      } catch (e) {
        actual = e.toString();
      }

      Assert.areEqual(expected, actual,
                      'Assert.isFalse() should use the default failure message ' +
                      'when no message was passed.');
    },

    testPassesSuppliedMessage: function() {
      var expected = 'This is the failure message.',
      actual = '';

      try {
        Assert.isFalse(true, expected);
      } catch (e) {
        actual = e.toString();
      }

      Assert.areEqual(expected, actual,
                      'Assert.isFalse() should use the user provided failure ' +
                      'message when provided.');
    }
  },

  /* Test Failures */
  FailureTest: {
    testBasicFailure: function() {
      Assert.fail('This test is supposed to fail.');
    },

    testWithDefaultMessage: function() {
      Assert.areEqual('this test will use', 'the default failure message');
    },

    testFailByException: function() {
      throw 'This test is supposed to throw an exception.';
    }
  }
};
